package sundial;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * Simple JUnit tests for computation module.  Checks logic.
 * 
 * @author Takanori Shiotsu
 * @author Reyn Matsumoto
 *
 */
public class SundialComputeTest {
	SundialCompute sc;
	
	@Before
	public void setUp() throws Exception {
		sc = new SundialCompute(21.3114, 157.7964, 10, 10, 2013, false);
	}
	
	@Test
	public void testSundialCompute() {
		assertTrue(sc.getMonth() < 13 && sc.getMonth() > 0);
		assertTrue(sc.getDay() < 32 && sc.getDay() > 0);
		assertTrue(sc.getLatitude() <= 90 && sc.getLatitude() >= -90);
		assertTrue(sc.getLongitude() <= 180 && sc.getLongitude() >= -180);
	}
	
	@Test
	public void testHourAngles() {
		Double[] shouldBeInRange = sc.hourAngles();
		boolean isInRange = true;
		for (int i=0; i<shouldBeInRange.length; i++) {
			if((shouldBeInRange[i] < -180) || (shouldBeInRange[i] > 180)) {
				isInRange = false;
			}
		}
		assertTrue(isInRange);
	}
	
	@Test
	public void testIntoRadians() {
		Double[] shouldBeInRadians = sc.intoRadians(sc.hourAngles());
		boolean isInRadians = true;
		for (int i=0; i<shouldBeInRadians.length; i++) {
			if ((shouldBeInRadians[i] < (-2 * Math.PI)) || (shouldBeInRadians[i] > (2 * Math.PI))) {
				isInRadians = false;
			}
		}
		assertTrue(isInRadians);
	}

	@Test
	public void testEOT() {
		double shouldBeInRange = sc.EOT();
		boolean isInRange = true;
		if ((shouldBeInRange < -15) || (shouldBeInRange > 16.5)) {
			isInRange = false;
		}
		assertTrue(isInRange);
	}

}
